<?php
    //添加管理员
    header("Access-Control-Allow-Origin: *"); // 允许跨域的地址，* 表示全部
    header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS"); // 允许的请求方法
    header("Access-Control-Allow-Headers: version, access-token, user-token"); // 允许的请求头属性

    include_once '../util/connect.php';

    $Phone = $_POST['Phone'];//手机号
    $Pwd = $_POST['AdminPassword'];//密码
    $ShopAddress = $_POST['ShopAddress'];//门店地址
    $AdminName = $_POST['AdminName'];//用户名
    date_default_timezone_set('PRC');
    $CreateTime = date("Y-m-d H:i:s");//注册时间

    $Pwd1 = $Pwd.'0xz765nb';//加盐拼接
    
    //加密后密码,加盐0xz765nb
    $AdminPassword =md5($Pwd1);
    
    $sql = " select * from admin where Phone='$Phone' ";
    $data = my_Select($sql);
    if ($data) {
        $arr = [
            "status" => 1,
            "message" => "手机号相同,不能重复注册"
        ];
    }else {
        $sql = "insert into admin(Phone,AdminPassword,ShopAddress,AdminName,CreateTime) values('$Phone','$AdminPassword','$ShopAddress','$AdminName','$CreateTime')";
        $data = my_ZSG($sql);
        if($data){
            $arr = [
                "status" => 0,
                "message" => "注册成功"
            ];
        }else{
            $arr = [
                "status" => 2,
                "message" => "注册失败"
            ];
        }
    }
    
        echo json_encode($arr,JSON_UNESCAPED_UNICODE);